/**
 * @file local_time.h
 * @brief Brief description of local_time.h
 * @author achdu0000@163.com
 * @version 1.0.0
 * @date 2024/07/07
 */

#ifndef LOCAL_TIME_H
#define LOCAL_TIME_H

#include <Arduino.h>
#include <lvgl.h>
#include "../../color_config/color_config.h"
#include "../../constants.h"

/**
 * set day of year value
 * @param jieqi_str                 the string of jieqi string in Chinese, like "立春", "雨水", ...
 * @param wuhou_index               the index of which wu hou, must only be in {1, 2, 3}
 * @return                          true if success
 */
bool set_jieqi_wuhou_val(const char *jieqi_str, uint8_t wuhou_index);

/**
 * set birth day of year value
 * @param birth_jieqi_str           the string of jieqi string in Chinese, like "立春", "雨水", ...
 * @param birth_wuhou_index         the index of which wu hou, must only be in {1, 2, 3}
 * @return                          true if success
 */
bool set_birth_jieqi_wuhou_val(const char *birth_jieqi_str, uint8_t birth_wuhou_index);

/**
 * set ganzhi of month (now)
 * @param month_ganzhi_s            the string of ganzhi string in Chinese, like "甲子", "乙丑", ...
 * @return                          true if success
 */
bool set_now_month_ganzhi(const char *month_ganzhi_s);

/**
 * get ganzhi of month (now)
 */
const char *get_now_month_ganzhi();

/**
 * set local gps val
 * @param longitude_deg             the degrees part of the longitude (0-180)
 * @param longitude_min             the minutes part of the longitude (0-59)
 * @param longitude_sec             the seconds part of the longitude (0-59)
 * @param latitude_deg              the degrees part of the latitude (0-90)
 * @param latitude_min              the minutes part of the latitude (0-59)
 * @param latitude_sec              the seconds part of the latitude (0-59)
 * @return                          true if success
 */
bool set_local_gps_val(uint8_t longitude_deg, uint8_t longitude_min, uint8_t longitude_sec, uint8_t latitude_deg, uint8_t latitude_min, uint8_t latitude_sec);

/**
 * set local sunrise and sunset value
 * @param sunrise_hour              the hour part of the sunrise time (0-23)
 * @param sunrise_min               the minute part of the sunrise time (0-59)
 * @param sunset_hour               the hour part of the sunset time (0-23)
 * @param sunset_min                the minute part of the sunset time (0-59)
 * @return                          true if success
 */
bool set_local_sunrise_and_sunset_val(uint8_t sunrise_hour, uint8_t sunrise_min, uint8_t sunset_hour, uint8_t sunset_min);

/**
 * set local moonrise and moonset value
 * @param moonrise_hour             the hour part of the moonrise time (0-23)
 * @param moonrise_min              the minute part of the moonrise time (0-59)
 * @param moonset_hour              the hour part of the moonset time (0-23)
 * @param moonset_min               the minute part of the moonset time (0-59)
 * @return                          true if success
 */
bool set_local_moonrise_and_moonset_val(uint8_t moonrise_hour, uint8_t moonrise_min, uint8_t moonset_hour, uint8_t moonset_min);

/**
 * create basic twenty four jieqi clock ui
 * @param parent                    the parent of the ui widgets in `lvgl`
 * @param width                     (lv_coord_t) width of ui
 * @param height                    (lv_coord_t) height of ui
 * @param content_w_ptr             (return) the width of content
 * @param content_h_ptr             (return) the height of content
 * @return                          true if success
 * @note                            the ui created will be center of the parent in default
 */
bool create_basic_twenty_four_jieqi_clock_ui(lv_obj_t *parent, lv_coord_t width, lv_coord_t height, lv_coord_t *content_w_ptr, lv_coord_t *content_h_ptr);

/**
 * create basic gps clock ui
 * @param parent                    the parent in lvgl widget
 * @param x_ofs                     the offset in direction x from the center of parent
 * @param y_ofs                     the offset in direction y from the center of parent
 * @return                          true if success
 */
bool create_basic_gps_icon_and_label_ui(lv_obj_t *parent, lv_coord_t x_ofs, lv_coord_t y_ofs);

/**
 * create extend 1 local ellipse and earth moon ui with canvas
 * @param parent                    the parent of the ui widgets in `lvgl`
 * @param canvas                    the canvas to draw
 * @param c_start_x                 the x coord of start pos on canvas
 * @param c_start_y                 the y coord of start pos on canvas
 * @param c_use_w                   the width used on canvas
 * @param c_use_h                   the height used on canvas
 * @param e_a                       (lv_coord_t) value a (in x direction) of ellipse
 * @param e_b                       (lv_coord_t) value b (in y direction) of ellipse
 * @return                          true if success
 */
bool create_extend_1_local_ellipse_and_earth_moon_ui_with_canvas(lv_obj_t *parent, lv_obj_t *canvas, lv_coord_t c_start_x, lv_coord_t c_start_y, lv_coord_t c_use_w, lv_coord_t c_use_h, lv_coord_t e_a, lv_coord_t e_b);

/**
 * create extend 1 sun time connect people ui, contains:
 *     - icon people to show the birth jieqi and wuhou
 * @param parent                    the parent in lvgl widget
 * @param border_radius             the radius of the border
 * @return                          true if success
 */
bool create_extend_1_local_time_connect_people_ui(lv_obj_t *parent, lv_coord_t border_radius);

/**
 * create extend 2 local sunrise and sunset time text label ui
 * @param parent                    the parent in lvgl widget
 * @param x_ofs                     the offset in direction x from the center of parent
 * @param y_ofs                     the offset in direction y from the center of parent
 * @return                          true if success
 */
bool create_extend_2_local_sunrise_and_sunset_ui(lv_obj_t *parent, lv_coord_t x_ofs, lv_coord_t y_ofs);

/**
 * create extend 2 local moonrise and moonset time text label ui
 * @param parent                    the parent in lvgl widget
 * @param x_ofs                     the offset in direction x from the center of parent
 * @param y_ofs                     the offset in direction y from the center of parent
 * @return                          true if success
 */
bool create_extend_2_local_moonrise_and_moonset_ui(lv_obj_t *parent, lv_coord_t x_ofs, lv_coord_t y_ofs);

/**
 * create extend 2 month ganzhi label ui
 * @param parent                    the parent in lvgl widget
 * @param x_ofs                     the offset in direction x from the center of parent
 * @param y_ofs                     the offset in direction y from the center of parent
 * @return                          true if success
 */
bool create_extend_2_month_ganzhi_label_ui(lv_obj_t *parent, lv_coord_t x_ofs, lv_coord_t y_ofs);

#endif // LOCAL_TIME_H
